// ProjectDBObjectGenerator.cpp: implementation of the ProjectDBObjectGenerator class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ProjectDBObjectGenerator.h"
#include "Phsapp.h"
#include "DBConnectionManager.h"
#include "Project.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

using namespace DAWrapper;

ProjectDBObjectGenerator::ProjectDBObjectGenerator()
{
}

ProjectDBObjectGenerator::~ProjectDBObjectGenerator()
{

}

BOOL ProjectDBObjectGenerator::GetRecordsetPtrWrap(const CString& strSql, RecordsetPtrWrap& rs)
{
	ASSERT(FALSE);
	ASSERT(!strSql.IsEmpty());
	ASSERT(!m_strPrjDB.IsEmpty());

	_ConnectionPtr* pCon = DBConnectionManager::Instance()->GetConnectionPtrByUri(m_strPrjDB);
	ASSERT(pCon);

	rs.Set(strSql, *pCon);
	if(rs.GetRecordCount() <= 0)
		return FALSE;
	return TRUE;
}

BOOL ProjectDBObjectGenerator::GetRecordsetPtrWrap(const CString& strSql, Project* pPrj, DAWrapper::RecordsetPtrWrap& rs)
{
	CString strSource = pPrj->ProjectPath() + pPrj->ProjectSource();
	_ConnectionPtr* pCon = DBConnectionManager::Instance()->GetConnectionPtrByUri(strSource);
	ASSERT(pCon);
	
	HRESULT hr = rs.Set(strSql, (*pCon));
	if(hr != S_OK)
	{
		ASSERT(FALSE);
		return FALSE;
	}
	return TRUE;
}